package com.shensi.appCollect.controller;

import com.shensi.api.admin.domian.station.ClassSettlement;
import com.shensi.appCollect.service.GzhNewsTemplateService;
import com.shensi.appCollect.service.IReceiptSectionService;
import com.shensi.appCollect.utils.ResultData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @date 2024/2/19
 */
@RestController
@RequestMapping("receiptSection")
@Api(tags = "小票打印设置")
public class ReceiptSectionController {

    @Autowired
    private IReceiptSectionService receiptSectionService;
    @Autowired
    private GzhNewsTemplateService gzhNewsTemplateService;


    @RequestMapping("getOrderReceiptString")
    public ResultData<String> getOrderReceiptString(@RequestParam("orderNo") String orderNo,
                                                    @RequestParam("deviceFactory") String deviceFactory,
                                                    @RequestParam("printType") String printType,
                                                    @RequestParam("his") boolean his) {
        return ResultData.success(gzhNewsTemplateService.getOrderReceiptString(orderNo, deviceFactory, printType, his));
    }

    /**
     * 班结小票打印格式获取
     *
     * @param printInfo
     * @return
     */
    @PostMapping("getClassSettlementReceiptString")
    public ResultData<String> getClassSettlementReceiptString(@RequestBody Map<String, Object> printInfo) {
        return ResultData.success(gzhNewsTemplateService.getClassSettlementReceiptString(printInfo));
    }

    /**
     * pos机班结动态格式获取
     *
     * @param classSettlement
     * @return
     */
    @PostMapping("getPosReceiptString")
    public ResultData<String> getPosReceiptString(@RequestBody @ApiParam(hidden = true) ClassSettlement classSettlement) {
        return ResultData.success(gzhNewsTemplateService.getPosReceiptString(classSettlement));
    }

    /**
     * pos机消费小票动态格式获取
     *
     * @param
     * @return
     */
    /**
     * pos机消费小票动态格式获取
     *
     * @param orderNo 订单号
     * @param deviceNo 设备号
     * @param extraPrint 是否补打
     * @return
     */
    @GetMapping("getPosOrderReceiptString")
    public ResultData<String> getPosOrderReceiptString(@RequestParam("orderNo") String orderNo, @RequestParam("deviceNo") String deviceNo, @RequestParam("extraPrint") boolean extraPrint) {
        return ResultData.success(gzhNewsTemplateService.getPosOrderReceiptString(orderNo,deviceNo,extraPrint));
    }

}
